package pers.myutil.local.conversion.data;

public class ByteConversion {

    /**
     * 将byte转为16进制
     * @param bytes byte参数
     * @return 十六进制字符串
     */
    public static String byteToHex(byte[] bytes) {
        StringBuilder stringBuilder = new StringBuilder();
        String temp = null;
        for (int i=0;i<bytes.length;i++){
            temp = Integer.toHexString(bytes[i] & 0xFF);
            if (temp.length()==1){
                //1得到一位的进行补0操作
                stringBuilder.append("0");
            }
            stringBuilder.append(temp);
        }
        return stringBuilder.toString();
    }


}
